﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WikiTrailCreator.TrailData;

namespace WikiTrailCreator.WikiGeneration
{
    public partial class ucWikiTextPanel : UserControl
    {
        private WikiPage wikiPage = null;

        public ucWikiTextPanel()
        {
            InitializeComponent();
        }

        private void textBoxCode_TextChanged(object sender, EventArgs e)
        {
            wikiPage.PageWikiCode = textBoxCode.Text;
        }

        public WikiPage WikiPage
        {
            get { return WikiPage; }
            set 
            { 
                wikiPage = value;
                textBoxCode.Text = value.PageWikiCode;

                this.URLForViewing = value.URLForViewing;
                this.URLForEditing = value.URLForEditing;
            }
        }

        public string URLForViewing
        {
            set { linkLabelView.Links[0].LinkData = value; }
        }

        public string URLForEditing
        {
            set { linkLabelEdit.Links[0].LinkData = value; }
        }

        private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
        }
    }
}
